package com.sanctity.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/***
 * @belongsProject spring-cloud
 * @description <医嘱开立MQ消息配置类>
 * @author Sanct
 * @version 1.0.0
 * @create 2024/1/25 10:52
 **/
@Configuration
public class OrderAuditMQConfig {

    private String orderAuditExchgNam="orderAuditExchange";

    private String orderAuditQueName="orderAuditQueue";

    private String orderAudiTopic="orderAudit.*";

    /**
     * 实例化交换机
     */
    @Bean(name = "orderAuditExchange")
    public Exchange orderAuditExchange(){
        return ExchangeBuilder.topicExchange(orderAuditExchgNam).build();
    }
    @Bean(name = "orderAuditQueue")
    public Queue orderAuditQueue(){
        return QueueBuilder.durable(orderAuditQueName).build();
    }

    @Bean
    public Binding orderAuditBinding(@Qualifier("orderAuditExchange") Exchange exchange,@Qualifier("orderAuditQueue") Queue queue){
        return BindingBuilder.bind(queue).to(exchange).with(orderAudiTopic).noargs();

    }
}
